<!--
 * @Descripttion: 意向客户特许经营市场变更记录 item
 * @version: 
 * @Author: lehaixia
 * @Date: 2023-04-19 15:20:53
 * @LastEditors: lehaixia
 * @LastEditTime: 2023-05-25 09:29:27
-->
<template>
  <div class="list-item">
    <div class="i-top">
      <div class="left">
        <img class="icon" src="@/assets/images/bill.png" />
        <span class="color-black">{{ getDictName('CTM_TOBE_CUS_MARKET_CHANGE_TYPE', itemData.changeType) }}</span>
      </div>
      <span class="right">{{ itemData.changeTime }}</span>
    </div>
    <div class="content">
      <div>
        变更人<span>{{ itemData.changeName }}</span>
      </div>
      <div>
        变更前市场<span>{{ itemData.changeBeforeMarketName }}</span>
      </div>
      <div>
        变更后市场<span>{{ itemData.changeAfterMarketName }}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
  import { defineComponent } from 'vue'
  export default defineComponent({
    name: 'PotentialCustomerMarketItem',
    props: {
      itemData: {
        type: Object,
        default: () => {}
      },
      dictData: {
        type: Object,
        default: () => {}
      }
    },
    setup(props, { emit }) {
      const onDetail = () => {
        emit('detail')
      }

      const getDictName = (dictType: string, code: any) => {
        if (!dictType || [undefined, null, ''].includes(code)) return ''
        let name = code
        const dictList = props.dictData[dictType] || []
        if (dictList.length > 0) {
          const obj = dictList.find((v: any) => v.dictCode === `${code}`)
          name = obj?.dictName || code
        }
        return name
      }

      return {
        onDetail,
        getDictName
      }
    }
  })
</script>
<style lang="less" scoped>
  .list-item {
    padding: 16px;
    background: var(--bg-global-weaker);
    font: var(--font-main-body);
    color: var(--texticon-default-stronger);
    // border-bottom: 1px solid var(--divisionline-weak);
    position: relative;

    &::after {
      content: '';
      position: absolute;
      left: 16px;
      right: 0;
      bottom: 0;
      width: calc(100% - 32px);
      height: 1px;
      background: var(--divisionline-weak);
    }

    &:last-child {
      &::after {
        display: none;
      }
    }

    .i-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 24px;
      font: var(--font-main-title-strengthen);

      .left {
        display: flex;
        align-items: center;

        img {
          width: 24px;
          height: 24px;
          margin-right: 4px;
        }
      }

      .right {
        color: var(--texticon-default-strong);
        font: var(--font-main-strengthen);
      }
    }

    .content {
      margin-top: 8px;
      div {
        padding: 2px 0;
        display: flex;
        justify-content: space-between;

        font: var(--font-main-body);
        color: var(--texticon-default-stronger);
        line-height: 20px;
      }
    }
  }
</style>
